def correct_sequence(s):
  stack = []
  opening_brackets = {"(", "[", "{", "<"}
  closing_brackets = {")", "]", "}", ">"}
  bracket = {")": "(", "]": "[", "}": "{", ">": "<"}
  for char in s:
      if char in opening_brackets:
          stack.append(char)
      elif char in closing_brackets:
          if not stack:
              return False
          if bracket[char] != stack[-1]:
              return False
          stack.pop()
  return not stack

sequence = input()
print(correct_sequence(sequence))
